/* 渲染到热销栏下 */
class hotGoods1{
    constructor(ops){
        this.hotGoods = ops.hotGoods;
        this.url = ops.url;
        this.load();
    }
    load(){
        request({
            url:this.url,
            success:(res)=>{
                this.res=(JSON.parse(res).hotSale.img);
                this.render();
            }
        });
    }
    render(){
        let str = "";
            for(var i=0;i<this.res.length;i++){
                str += `
                <div class="box" index="${this.res[i]}">
                <img src="${this.res[i].url}" alt="">
                <p>${this.res[i].name}</p>
                <span>${this.res[i].price}</span>
                </div>
                `    
            }
        this.hotGoods.innerHTML = str;
    }
}

new hotGoods1({
    box:document.querySelectorAll(".hotGoods>.box"),
    hotGoods:document.querySelector(".hotGoods"),
    url:"./json/list.json"
});